package tools.Derby;
import java.sql.Statement;
import java.sql.Connection;
import java.sql.ResultSet;

/**
 *
 * @author hgs
 */
public class DerbyConnection {

    private String dbName = "";
    private String name ;
    private String password ;
    private String JdbcType;
    private Connection con;
    private String url;
    private GeneralConnection co = new GeneralConnection();

    public Connection getConnection() {
        this.con = this.co.Setupconnection(this.url, this.name, this.password, this.JdbcType);
        return con;
    }

    public void closeConnection(Connection c) {
        this.co.closeData(c);
    }

    public ResultSet getResult(String sqlString, Connection con) {
        Statement stmt;
        ResultSet rs = null;
        System.out.println(sqlString);
        try {
            stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
            rs = stmt.executeQuery(sqlString);
        } catch (java.sql.SQLException ex) {
        }
        return rs;
    }

    /**
     * @param dbName the dbName to set
     */
    public void setDbName(String dbName) {
        this.dbName = dbName;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @param password the password to set
     */
    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * @param JdbcType the JdbcType to set
     */
    public void setJdbcType(String JdbcType) {
        this.JdbcType = JdbcType;
    }

    /**
     * @param url the url to set
     */
    public void setUrl(String url) {
        this.url = url;
    }

}
